import React from 'react';
import {Card, Descriptions} from "antd";
import {Link, useLocation} from "react-router-dom";
import {getTag} from "util/ColumnsUtil";
import {SecurityRole} from "type/SecurityRole";

const RoleDetailsComponent = () => {
    const role: SecurityRole = useLocation().state ;

    return (
        <Card
            title={"角色详细信息"}
            extra={ <Link key={"role-list"} to={"../"}>角色列表</Link> }
        >
            <Descriptions
                bordered={true}
                column={2}
                items={[
                    {
                        key: 'id',
                        label: '角色编号',
                        children: role.id
                    },
                    {
                        key: 'key',
                        label: '唯一表示',
                        children: role.key
                    },
                    {
                        key: 'authority',
                        label: '角色描述',
                        children: role.authority
                    },
                    {
                        key: 'explain',
                        label: '角色说明',
                        children: role.explain
                    },
                    {
                        key: 'weight',
                        label: '角色权重',
                        children: role.weight
                    },
                    {
                        key: 'version',
                        label: '数据版本',
                        children: role.version
                    },
                    {
                        key: 'createTime',
                        label: '创建时间',
                        children: role.createTime.toString()
                    },
                    {
                        key: 'updateTime',
                        label: '更新时间',
                        children: role.updateTime.toString()
                    },
                    {
                        key: 'delete',
                        label: '逻辑删除',
                        children: getTag(!role.delete,"未删除","已删除")
                    },
                    {
                        key: 'remark',
                        label: '备注信息',
                        children: role.remark
                    }
                ]}
            />
        </Card>
    );
};

export default RoleDetailsComponent;